using SM.core;
using SS;
using SS.core;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Windows.Forms;
using TVSGPP.chart;
namespace TVSBH.func
{
	public class frmPriceChange : Form
	{
		private IContainer components = null;
		private GroupBox groupBox1;
		private Label label1;
		private Label label3;
		private DateTimePicker txtfromDay;
		private DateTimePicker txttoDay;
		private Label label4;
		private DataGridView dgvProduct;
		private Button btnClose;
		private Label lblMinPrice;
		private Label label5;
		private Label lblMaxPrice;
		private Label label9;
		private Label lblAvgPrice;
		private Label label7;
		private Label lblCurrPrice;
		private Label label8;
		private Button btnChart;
		private SplitContainer splitContainer1;
		private TextBox txtSearch;
		private DataGridView dgvListProduct;
		private GroupBox groupBox3;
		private Label lblCurrProduct;
		private DataGridViewTextBoxColumn Column7;
		private DataGridViewTextBoxColumn Column2;
		private DataGridViewTextBoxColumn Column3;
		private DataGridViewTextBoxColumn Column8;
		private DataGridViewTextBoxColumn Column1;
		private DataGridViewTextBoxColumn Column9;
		private DataGridViewTextBoxColumn dg2;
		private DataGridViewTextBoxColumn dg6;
		private Func objFunc = new Func();
		private DataTable objTable = new DataTable();
		private Bill objBill = new Bill();
		private products objP = new products();
		private bool isPostBack = false;
		public ArrayList listPrice = new ArrayList();
		public ArrayList listTime = new ArrayList();
		public ArrayList listDistance = new ArrayList();
		private int currProductID = 0;
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			DataGridViewCellStyle dataGridViewCellStyle = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle4 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle5 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle6 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle7 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle8 = new DataGridViewCellStyle();
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(frmPriceChange));
			this.groupBox1 = new GroupBox();
			this.label4 = new Label();
			this.txttoDay = new DateTimePicker();
			this.label3 = new Label();
			this.txtfromDay = new DateTimePicker();
			this.dgvListProduct = new DataGridView();
			this.dg2 = new DataGridViewTextBoxColumn();
			this.dg6 = new DataGridViewTextBoxColumn();
			this.txtSearch = new TextBox();
			this.label1 = new Label();
			this.dgvProduct = new DataGridView();
			this.Column7 = new DataGridViewTextBoxColumn();
			this.Column2 = new DataGridViewTextBoxColumn();
			this.Column3 = new DataGridViewTextBoxColumn();
			this.Column8 = new DataGridViewTextBoxColumn();
			this.Column1 = new DataGridViewTextBoxColumn();
			this.Column9 = new DataGridViewTextBoxColumn();
			this.btnClose = new Button();
			this.lblCurrPrice = new Label();
			this.label8 = new Label();
			this.lblMaxPrice = new Label();
			this.label9 = new Label();
			this.lblAvgPrice = new Label();
			this.label7 = new Label();
			this.lblMinPrice = new Label();
			this.label5 = new Label();
			this.btnChart = new Button();
			this.splitContainer1 = new SplitContainer();
			this.groupBox3 = new GroupBox();
			this.lblCurrProduct = new Label();
			this.groupBox1.SuspendLayout();
			((ISupportInitialize)this.dgvListProduct).BeginInit();
			((ISupportInitialize)this.dgvProduct).BeginInit();
			this.splitContainer1.SuspendLayout();
			this.groupBox3.SuspendLayout();
			base.SuspendLayout();
			this.groupBox1.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left);
			this.groupBox1.Controls.Add(this.label4);
			this.groupBox1.Controls.Add(this.txttoDay);
			this.groupBox1.Controls.Add(this.label3);
			this.groupBox1.Controls.Add(this.txtfromDay);
			this.groupBox1.Controls.Add(this.dgvListProduct);
			this.groupBox1.Controls.Add(this.txtSearch);
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.groupBox1.Location = new System.Drawing.Point(7, 2);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new Size(292, 255);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Thông tin tìm kiếm";
			this.label4.AutoSize = true;
			this.label4.Font = new Font("Arial", 9f);
			this.label4.Location = new System.Drawing.Point(169, 30);
			this.label4.Name = "label4";
			this.label4.Size = new Size(11, 15);
			this.label4.TabIndex = 55;
			this.label4.Text = "-";
			this.txttoDay.CustomFormat = "dd/MM/yyyy";
			this.txttoDay.Font = new Font("Arial", 9f);
			this.txttoDay.Format = DateTimePickerFormat.Custom;
			this.txttoDay.Location = new System.Drawing.Point(183, 27);
			this.txttoDay.Name = "txttoDay";
			this.txttoDay.Size = new Size(100, 21);
			this.txttoDay.TabIndex = 54;
			this.label3.AutoSize = true;
			this.label3.Font = new Font("Arial", 9f);
			this.label3.Location = new System.Drawing.Point(7, 30);
			this.label3.Name = "label3";
			this.label3.Size = new Size(57, 15);
			this.label3.TabIndex = 53;
			this.label3.Text = "Từ ngày :";
			this.txtfromDay.CustomFormat = "dd/MM/yyyy";
			this.txtfromDay.Font = new Font("Arial", 9f);
			this.txtfromDay.Format = DateTimePickerFormat.Custom;
			this.txtfromDay.Location = new System.Drawing.Point(66, 27);
			this.txtfromDay.Name = "txtfromDay";
			this.txtfromDay.Size = new Size(100, 21);
			this.txtfromDay.TabIndex = 52;
			this.dgvListProduct.AllowUserToAddRows = false;
			this.dgvListProduct.AllowUserToDeleteRows = false;
			this.dgvListProduct.AllowUserToResizeColumns = false;
			this.dgvListProduct.AllowUserToResizeRows = false;
			dataGridViewCellStyle.BackColor = Color.FromArgb(192, 255, 255);
			dataGridViewCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.dgvListProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle;
			this.dgvListProduct.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left);
			this.dgvListProduct.BackgroundColor = Color.White;
			this.dgvListProduct.BorderStyle = BorderStyle.Fixed3D;
			this.dgvListProduct.CellBorderStyle = DataGridViewCellBorderStyle.Raised;
			this.dgvListProduct.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None;
			dataGridViewCellStyle2.BackColor = SystemColors.Control;
			dataGridViewCellStyle2.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			dataGridViewCellStyle2.ForeColor = SystemColors.WindowText;
			dataGridViewCellStyle2.SelectionBackColor = Color.Aqua;
			dataGridViewCellStyle2.SelectionForeColor = Color.Black;
			this.dgvListProduct.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
			this.dgvListProduct.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.dgvListProduct.Columns.AddRange(new DataGridViewColumn[]
			{
				this.dg2,
				this.dg6
			});
			this.dgvListProduct.Cursor = Cursors.Hand;
			this.dgvListProduct.Location = new System.Drawing.Point(10, 111);
			this.dgvListProduct.MultiSelect = false;
			this.dgvListProduct.Name = "dgvListProduct";
			this.dgvListProduct.ReadOnly = true;
			dataGridViewCellStyle3.BackColor = SystemColors.Control;
			dataGridViewCellStyle3.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			dataGridViewCellStyle3.ForeColor = Color.Black;
			dataGridViewCellStyle3.SelectionBackColor = Color.Aqua;
			dataGridViewCellStyle3.SelectionForeColor = Color.Black;
			this.dgvListProduct.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
			this.dgvListProduct.RowHeadersVisible = false;
			this.dgvListProduct.RowHeadersWidth = 26;
			this.dgvListProduct.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
			dataGridViewCellStyle4.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvListProduct.RowsDefaultCellStyle = dataGridViewCellStyle4;
			this.dgvListProduct.RowTemplate.DefaultCellStyle.BackColor = Color.White;
			this.dgvListProduct.RowTemplate.DefaultCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.dgvListProduct.RowTemplate.DefaultCellStyle.ForeColor = Color.Black;
			this.dgvListProduct.RowTemplate.DefaultCellStyle.SelectionBackColor = Color.Aqua;
			this.dgvListProduct.RowTemplate.DefaultCellStyle.SelectionForeColor = Color.Black;
			this.dgvListProduct.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
			this.dgvListProduct.Size = new Size(273, 138);
			this.dgvListProduct.TabIndex = 95;
			this.dgvListProduct.CellEnter += new DataGridViewCellEventHandler(this.dgvListProduct_CellEnter);
			this.dg2.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.dg2.DataPropertyName = "ProductName";
			dataGridViewCellStyle5.Alignment = DataGridViewContentAlignment.MiddleLeft;
			dataGridViewCellStyle5.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle5.NullValue = null;
			this.dg2.DefaultCellStyle = dataGridViewCellStyle5;
			this.dg2.HeaderText = "Tên sản phẩm";
			this.dg2.MinimumWidth = 120;
			this.dg2.Name = "dg2";
			this.dg2.ReadOnly = true;
			this.dg6.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dg6.DataPropertyName = "PID";
			this.dg6.HeaderText = "PID";
			this.dg6.Name = "dg6";
			this.dg6.ReadOnly = true;
			this.dg6.Resizable = DataGridViewTriState.False;
			this.dg6.Visible = false;
			this.dg6.Width = 5;
			this.txtSearch.BackColor = Color.White;
			this.txtSearch.Font = new Font("Arial", 11.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtSearch.Location = new System.Drawing.Point(10, 83);
			this.txtSearch.Name = "txtSearch";
			this.txtSearch.Size = new Size(273, 25);
			this.txtSearch.TabIndex = 56;
			this.txtSearch.TextChanged += new EventHandler(this.txtSearch_TextChanged);
			this.label1.AutoSize = true;
			this.label1.Font = new Font("Arial", 9f);
			this.label1.Location = new System.Drawing.Point(8, 64);
			this.label1.Name = "label1";
			this.label1.Size = new Size(93, 15);
			this.label1.TabIndex = 47;
			this.label1.Text = "Tìm sản phẩm :";
			this.dgvProduct.AllowUserToAddRows = false;
			this.dgvProduct.AllowUserToDeleteRows = false;
			this.dgvProduct.AllowUserToOrderColumns = true;
			this.dgvProduct.AllowUserToResizeColumns = false;
			this.dgvProduct.AllowUserToResizeRows = false;
			dataGridViewCellStyle6.BackColor = Color.FromArgb(192, 255, 255);
			dataGridViewCellStyle6.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6;
			this.dgvProduct.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.dgvProduct.BackgroundColor = Color.White;
			this.dgvProduct.BorderStyle = BorderStyle.Fixed3D;
			this.dgvProduct.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
			this.dgvProduct.Columns.AddRange(new DataGridViewColumn[]
			{
				this.Column7,
				this.Column2,
				this.Column3,
				this.Column8,
				this.Column1,
				this.Column9
			});
			this.dgvProduct.Cursor = Cursors.Hand;
			this.dgvProduct.EnableHeadersVisualStyles = false;
			this.dgvProduct.Location = new System.Drawing.Point(305, 85);
			this.dgvProduct.MultiSelect = false;
			this.dgvProduct.Name = "dgvProduct";
			this.dgvProduct.ReadOnly = true;
			this.dgvProduct.RowHeadersVisible = false;
			this.dgvProduct.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
			this.dgvProduct.RowTemplate.DefaultCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvProduct.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
			this.dgvProduct.Size = new Size(589, 172);
			this.dgvProduct.TabIndex = 2;
			this.Column7.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Column7.DataPropertyName = "CreateDate";
			dataGridViewCellStyle7.Format = "D";
			dataGridViewCellStyle7.NullValue = null;
			this.Column7.DefaultCellStyle = dataGridViewCellStyle7;
			this.Column7.HeaderText = "Ngày HĐ";
			this.Column7.MinimumWidth = 100;
			this.Column7.Name = "Column7";
			this.Column7.ReadOnly = true;
			this.Column2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Column2.DataPropertyName = "BillID";
			this.Column2.HeaderText = "Hoá đơn";
			this.Column2.MinimumWidth = 150;
			this.Column2.Name = "Column2";
			this.Column2.ReadOnly = true;
			this.Column2.Width = 150;
			this.Column3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Column3.DataPropertyName = "productUnit";
			this.Column3.HeaderText = "Đơn vị tính";
			this.Column3.MinimumWidth = 150;
			this.Column3.Name = "Column3";
			this.Column3.ReadOnly = true;
			this.Column3.Width = 150;
			this.Column8.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Column8.DataPropertyName = "productPrice";
			dataGridViewCellStyle8.Alignment = DataGridViewContentAlignment.MiddleRight;
			dataGridViewCellStyle8.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.Column8.DefaultCellStyle = dataGridViewCellStyle8;
			this.Column8.HeaderText = "Đơn giá";
			this.Column8.MinimumWidth = 100;
			this.Column8.Name = "Column8";
			this.Column8.ReadOnly = true;
			this.Column1.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.Column1.DataPropertyName = "Packet";
			this.Column1.HeaderText = "Lô hàng";
			this.Column1.Name = "Column1";
			this.Column1.ReadOnly = true;
			this.Column9.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Column9.DataPropertyName = "Pid";
			this.Column9.HeaderText = "Mã sản phẩm";
			this.Column9.Name = "Column9";
			this.Column9.ReadOnly = true;
			this.Column9.Visible = false;
			this.btnClose.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			this.btnClose.FlatAppearance.BorderColor = Color.FromArgb(255, 128, 255);
			this.btnClose.FlatStyle = FlatStyle.Flat;
			this.btnClose.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnClose.Location = new System.Drawing.Point(796, 568);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new Size(97, 26);
			this.btnClose.TabIndex = 42;
			this.btnClose.Text = "Thoát  [ ESC ]";
			this.btnClose.UseVisualStyleBackColor = true;
			this.btnClose.Click += new EventHandler(this.btnClose_Click);
			this.lblCurrPrice.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.lblCurrPrice.BackColor = Color.White;
			this.lblCurrPrice.BorderStyle = BorderStyle.Fixed3D;
			this.lblCurrPrice.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.lblCurrPrice.Location = new System.Drawing.Point(781, 21);
			this.lblCurrPrice.Name = "lblCurrPrice";
			this.lblCurrPrice.Size = new Size(103, 22);
			this.lblCurrPrice.TabIndex = 7;
			this.lblCurrPrice.Text = "-:-";
			this.lblCurrPrice.TextAlign = ContentAlignment.MiddleLeft;
			this.label8.AutoSize = true;
			this.label8.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.label8.Location = new System.Drawing.Point(397, 23);
			this.label8.Name = "label8";
			this.label8.Size = new Size(75, 15);
			this.label8.TabIndex = 6;
			this.label8.Text = "Giá hiện tại :";
			this.lblMaxPrice.BackColor = Color.White;
			this.lblMaxPrice.BorderStyle = BorderStyle.Fixed3D;
			this.lblMaxPrice.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.lblMaxPrice.ForeColor = Color.Blue;
			this.lblMaxPrice.Location = new System.Drawing.Point(394, 49);
			this.lblMaxPrice.Name = "lblMaxPrice";
			this.lblMaxPrice.Size = new Size(102, 20);
			this.lblMaxPrice.TabIndex = 5;
			this.lblMaxPrice.Text = "-:-";
			this.lblMaxPrice.TextAlign = ContentAlignment.MiddleLeft;
			this.label9.AutoSize = true;
			this.label9.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.label9.Location = new System.Drawing.Point(309, 51);
			this.label9.Name = "label9";
			this.label9.Size = new Size(82, 15);
			this.label9.TabIndex = 4;
			this.label9.Text = "Giá cao nhất :";
			this.lblAvgPrice.BackColor = Color.White;
			this.lblAvgPrice.BorderStyle = BorderStyle.Fixed3D;
			this.lblAvgPrice.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.lblAvgPrice.Location = new System.Drawing.Point(593, 49);
			this.lblAvgPrice.Name = "lblAvgPrice";
			this.lblAvgPrice.Size = new Size(95, 20);
			this.lblAvgPrice.TabIndex = 3;
			this.lblAvgPrice.Text = "-:-";
			this.lblAvgPrice.TextAlign = ContentAlignment.MiddleLeft;
			this.label7.AutoSize = true;
			this.label7.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.label7.Location = new System.Drawing.Point(500, 51);
			this.label7.Name = "label7";
			this.label7.Size = new Size(90, 15);
			this.label7.TabIndex = 2;
			this.label7.Text = "Giá trung bình :";
			this.lblMinPrice.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.lblMinPrice.BackColor = Color.White;
			this.lblMinPrice.BorderStyle = BorderStyle.Fixed3D;
			this.lblMinPrice.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.lblMinPrice.ForeColor = Color.Red;
			this.lblMinPrice.Location = new System.Drawing.Point(781, 49);
			this.lblMinPrice.Name = "lblMinPrice";
			this.lblMinPrice.Size = new Size(103, 20);
			this.lblMinPrice.TabIndex = 1;
			this.lblMinPrice.Text = "-:-";
			this.lblMinPrice.TextAlign = ContentAlignment.MiddleLeft;
			this.label5.AutoSize = true;
			this.label5.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.label5.Location = new System.Drawing.Point(692, 51);
			this.label5.Name = "label5";
			this.label5.Size = new Size(86, 15);
			this.label5.TabIndex = 0;
			this.label5.Text = "Giá thấp nhất :";
			this.btnChart.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnChart.FlatAppearance.BorderColor = Color.FromArgb(255, 128, 255);
			this.btnChart.FlatStyle = FlatStyle.Flat;
			this.btnChart.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnChart.Location = new System.Drawing.Point(7, 568);
			this.btnChart.Name = "btnChart";
			this.btnChart.Size = new Size(111, 26);
			this.btnChart.TabIndex = 47;
			this.btnChart.Text = "Biểu đồ kỹ thuật";
			this.btnChart.UseVisualStyleBackColor = true;
			this.btnChart.Click += new EventHandler(this.btnChart_Click);
			this.splitContainer1.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.splitContainer1.Location = new System.Drawing.Point(7, 263);
			this.splitContainer1.Name = "splitContainer1";
			this.splitContainer1.Panel1Collapsed = true;
			this.splitContainer1.Panel2.BackColor = Color.White;
			this.splitContainer1.Size = new Size(887, 299);
			this.splitContainer1.SplitterDistance = 295;
			this.splitContainer1.TabIndex = 48;
			this.groupBox3.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.groupBox3.Controls.Add(this.lblCurrProduct);
			this.groupBox3.Controls.Add(this.label8);
			this.groupBox3.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.groupBox3.Location = new System.Drawing.Point(305, 2);
			this.groupBox3.Name = "groupBox3";
			this.groupBox3.Size = new Size(589, 77);
			this.groupBox3.TabIndex = 96;
			this.groupBox3.TabStop = false;
			this.groupBox3.Text = "Thống kê nhanh";
			this.lblCurrProduct.BackColor = Color.FromArgb(255, 255, 192);
			this.lblCurrProduct.BorderStyle = BorderStyle.Fixed3D;
			this.lblCurrProduct.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.lblCurrProduct.Location = new System.Drawing.Point(89, 19);
			this.lblCurrProduct.Name = "lblCurrProduct";
			this.lblCurrProduct.Size = new Size(294, 22);
			this.lblCurrProduct.TabIndex = 8;
			this.lblCurrProduct.Text = "-:-";
			this.lblCurrProduct.TextAlign = ContentAlignment.MiddleLeft;
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			this.BackColor = Color.White;
			base.ClientSize = new Size(900, 600);
			base.Controls.Add(this.lblMinPrice);
			base.Controls.Add(this.label5);
			base.Controls.Add(this.lblAvgPrice);
			base.Controls.Add(this.label7);
			base.Controls.Add(this.lblMaxPrice);
			base.Controls.Add(this.label9);
			base.Controls.Add(this.lblCurrPrice);
			base.Controls.Add(this.splitContainer1);
			base.Controls.Add(this.btnChart);
			base.Controls.Add(this.btnClose);
			base.Controls.Add(this.groupBox1);
			base.Controls.Add(this.dgvProduct);
			base.Controls.Add(this.groupBox3);
			this.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			//base.Icon = (System.Drawing.Icon)componentResourceManager.GetObject("$this.Icon");
			//base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
			base.Name = "frmPriceChange";
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "BIẾN ĐỘNG GIÁ";
			base.Load += new EventHandler(this.frmStorageCard_Load);
			this.groupBox1.ResumeLayout(false);
			this.groupBox1.PerformLayout();
			((ISupportInitialize)this.dgvListProduct).EndInit();
			((ISupportInitialize)this.dgvProduct).EndInit();
			this.splitContainer1.ResumeLayout(false);
			this.groupBox3.ResumeLayout(false);
			this.groupBox3.PerformLayout();
			base.ResumeLayout(false);
			base.PerformLayout();
		}
		public frmPriceChange()
		{
			this.InitializeComponent();
		}
		private void frmStorageCard_Load(object sender, EventArgs e)
		{
			this.txtfromDay.Value = DateTime.Now.AddDays(-30.0);
			this.dgvProduct.AutoGenerateColumns = false;
			Program.strConnectionString = this.objFunc.strConnectionString;
			this.isPostBack = true;
		}
		public void getDetailBalancer(string pid)
		{
			try
			{
				this.listPrice.Clear();
				this.listTime.Clear();
				this.listDistance.Clear();
				DataTable dataTable = new DataTable();
				DataColumn column = new DataColumn("Pid", typeof(string));
				DataColumn column2 = new DataColumn("CreateDate", typeof(string));
				DataColumn column3 = new DataColumn("BillID", typeof(string));
				DataColumn column4 = new DataColumn("ProductUnit", typeof(string));
				DataColumn column5 = new DataColumn("ProductPrice", typeof(string));
				DataColumn column6 = new DataColumn("Packet", typeof(string));
				dataTable.Columns.Add(column);
				dataTable.Columns.Add(column2);
				dataTable.Columns.Add(column3);
				dataTable.Columns.Add(column4);
				dataTable.Columns.Add(column5);
				dataTable.Columns.Add(column6);
				SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
				sqlConnection.Open();
				SqlParameter sqlParameter = new SqlParameter("objDate1", SqlDbType.DateTime);
				SqlParameter sqlParameter2 = new SqlParameter("objDate2", SqlDbType.DateTime);
				sqlParameter.Value = DateTime.Parse(this.txtfromDay.Value.ToString().Substring(0, 10) + " 00:00:00 AM");
				sqlParameter2.Value = DateTime.Parse(this.txttoDay.Value.ToString().Substring(0, 10) + " 11:59:59 PM");
				SqlCommand sqlCommand = sqlConnection.CreateCommand();
				sqlCommand.Parameters.Add(sqlParameter);
				sqlCommand.Parameters.Add(sqlParameter2);
				string text = "";
				string text2 = " AND [TabDetailBill].[Pid] = " + pid;
				sqlCommand.CommandText = string.Concat(new string[]
				{
					"SELECT * FROM [TabDetailBill],[TabBill] WHERE [TypeInput] IN ('IN1','IN2','IN3') ",
					text,
					" AND [TabDetailBill].[billID] = [TabBill].[ID] ",
					text2,
					" AND [TabBill].[CreateDate] BETWEEN @objDate1 AND @objDate2 ORDER BY [TabBill].[CreateDate] ASC"
				});
				SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
				TimeSpan timeSpan;
				while (sqlDataReader.Read())
				{
					string text3;
					if (this.checkInObjTable(sqlDataReader["CreateDate"].ToString(), dataTable))
					{
						text3 = "";
					}
					else
					{
						text3 = sqlDataReader["CreateDate"].ToString().Substring(0, 10);
						this.listPrice.Add(sqlDataReader["ProductPrice"].ToString());
						this.listTime.Add(text3);
						timeSpan = DateTime.Parse(DateTime.Parse(sqlDataReader["CreateDate"].ToString()).ToShortDateString()).Subtract(DateTime.Parse(this.txtfromDay.Value.ToShortDateString()));
						this.listDistance.Add(timeSpan.TotalDays);
					}
					string text4 = " " + sqlDataReader["Packet"].ToString();
					dataTable.Rows.Add(new object[]
					{
						sqlDataReader["Pid"].ToString(),
						text3,
						sqlDataReader["billID"].ToString(),
						" " + sqlDataReader["ProductUnit"].ToString(),
						string.Format(Program.lenAffterDecimal, float.Parse(sqlDataReader["ProductPrice"].ToString())),
						text4
					});
					this.currProductID = int.Parse(sqlDataReader["Pid"].ToString());
					this.lblCurrProduct.Text = sqlDataReader["ProductName"].ToString();
				}
				sqlDataReader.Close();
				timeSpan = DateTime.Parse(this.txttoDay.Value.ToShortDateString()).Subtract(DateTime.Parse(this.txtfromDay.Value.ToShortDateString()));
				this.listDistance.Add(timeSpan.TotalDays);
				sqlConnection.Close();
				sqlConnection.Dispose();
				this.objTable = dataTable;
				this.dgvProduct.DataSource = this.objTable;
			}
			catch
			{
				this.objTable = null;
				this.dgvProduct.DataSource = this.objTable;
				this.lblAvgPrice.Text = "-:-";
				this.lblCurrPrice.Text = "-:-";
				this.lblMaxPrice.Text = "-:-";
				this.lblMinPrice.Text = "-:-";
				this.lblCurrProduct.Text = "-:-";
			}
		}
		private bool checkInObjTable(string tmpDate, DataTable tmpTbale)
		{
			bool flag = false;
			bool result;
			for (int i = 0; i < tmpTbale.Rows.Count; i++)
			{
				if (tmpTbale.Rows[i]["CreateDate"].ToString() == tmpDate.Substring(0, 10))
				{
					flag = true;
					result = flag;
					return result;
				}
			}
			result = flag;
			return result;
		}
		private void btnClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void cbbProduct_SelectedValueChanged(object sender, EventArgs e)
		{
			this.getDetailBalancer("");
			if (this.isPostBack)
			{
				this.lblAvgPrice.Text = string.Format(Program.lenAffterDecimal, this.objP.getPriceInAVGInAnRan(this.currProductID.ToString(), this.txtfromDay.Value, this.txttoDay.Value));
				this.lblMaxPrice.Text = string.Format(Program.lenAffterDecimal, this.objP.getPriceInMaxInAnRan(this.currProductID.ToString(), this.txtfromDay.Value, this.txttoDay.Value));
				this.lblMinPrice.Text = string.Format(Program.lenAffterDecimal, this.objP.getPriceInMinInAnRan(this.currProductID.ToString(), this.txtfromDay.Value, this.txttoDay.Value));
				this.lblCurrPrice.Text = string.Format(Program.lenAffterDecimal, this.objP.getPriceInCurrent(this.currProductID.ToString()));
			}
		}
		private void btnChart_Click(object sender, EventArgs e)
		{
			try
			{
				this.getDetailBalancer("");
				this.splitContainer1.Panel2.Controls.Clear();
				frmPriceInChart frmPriceInChart = new frmPriceInChart();
				frmPriceInChart.TopLevel = false;
				frmPriceInChart.Location = new System.Drawing.Point(10, 10);
				frmPriceInChart.listPrice = this.listPrice;
				frmPriceInChart.listTime = this.listTime;
				frmPriceInChart.listDistance = this.listDistance;
				frmPriceInChart.maxValue = float.Parse(this.lblMaxPrice.Text);
				frmPriceInChart.minValue = float.Parse(this.lblMinPrice.Text);
				frmPriceInChart.avgValue = float.Parse(this.lblAvgPrice.Text);
				frmPriceInChart.Width = this.splitContainer1.Panel2.Width - 20;
				this.splitContainer1.Panel2.Controls.Add(frmPriceInChart);
				frmPriceInChart.Show();
			}
			catch
			{
			}
		}
		private void txtSearch_TextChanged(object sender, EventArgs e)
		{
			if (this.isPostBack)
			{
				this.getProduct(this.txtSearch.Text);
			}
		}
		private void getProduct(string pName)
		{
			try
			{
				this.dgvListProduct.AutoGenerateColumns = false;
				SqlConnection sqlConnection = new SqlConnection(this.objFunc.strConnectionString);
				SqlParameter sqlParameter = new SqlParameter("objDate1", SqlDbType.DateTime);
				SqlParameter sqlParameter2 = new SqlParameter("objDate2", SqlDbType.DateTime);
				sqlParameter.Value = DateTime.Parse(this.txtfromDay.Value.ToString().Substring(0, 10) + " 00:00:00 AM");
				sqlParameter2.Value = DateTime.Parse(this.txttoDay.Value.ToString().Substring(0, 10) + " 11:59:59 PM");
				SqlCommand sqlCommand = sqlConnection.CreateCommand();
				sqlCommand.Parameters.Add(sqlParameter);
				sqlCommand.Parameters.Add(sqlParameter2);
				string commandText = "SELECT * FROM [TabDetailBill],[TabBill] WHERE [TypeInput] IN ('IN1','IN2','IN3') AND [TabDetailBill].[billID] = [TabBill].[ID] AND [TabBill].[CreateDate] BETWEEN @objDate1 AND @objDate2 AND [TabDetailBill].[ProductName] LIKE N'%" + this.txtSearch.Text.ToUpper() + "%' ORDER BY [TabBill].[CreateDate] ASC";
				sqlCommand.CommandText = commandText;
				SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
				DataSet dataSet = new DataSet();
				sqlConnection.Open();
				sqlDataAdapter.Fill(dataSet);
				this.dgvListProduct.DataSource = dataSet.Tables[0];
				sqlConnection.Close();
				sqlConnection.Dispose();
				sqlDataAdapter.Dispose();
				dataSet.Dispose();
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
		private void dgvListProduct_CellEnter(object sender, DataGridViewCellEventArgs e)
		{
			try
			{
				this.getDetailBalancer(this.dgvListProduct.Rows[e.RowIndex].Cells["dg6"].Value.ToString());
				if (this.isPostBack)
				{
					this.lblAvgPrice.Text = string.Format(Program.lenAffterDecimal, this.objP.getPriceInAVGInAnRan(this.currProductID.ToString(), this.txtfromDay.Value, this.txttoDay.Value));
					this.lblMaxPrice.Text = string.Format(Program.lenAffterDecimal, this.objP.getPriceInMaxInAnRan(this.currProductID.ToString(), this.txtfromDay.Value, this.txttoDay.Value));
					this.lblMinPrice.Text = string.Format(Program.lenAffterDecimal, this.objP.getPriceInMinInAnRan(this.currProductID.ToString(), this.txtfromDay.Value, this.txttoDay.Value));
					this.lblCurrPrice.Text = string.Format(Program.lenAffterDecimal, this.objP.getPriceInCurrent(this.currProductID.ToString()));
				}
			}
			catch
			{
			}
		}
	}
}
